          <!DOCTYPE html>
          <html lang="zh-cn">
          <head>
              <meta charset="utf-8">
              <meta http-equiv="X-UA-Compatible" content="IE=edge">
              <meta name="viewport" content="width=device-width, initial-scale=1">
              <meta name="description" content="">
              <meta name="author" content="">
              <link rel="icon" href="../../favicon.ico">

              <title>Off Canvas Template for Bootstrap</title>

              <!-- Bootstrap core CSS -->
              <link href="assets/css/bootstrap.min.css" rel="stylesheet">

              <!-- Custom styles for this template -->
              <link href="assets/css/offcanvas.css" rel="stylesheet">
              <link href="assets/css/style.css" rel="stylesheet">
              <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
              <!--[if lt IE 9]>
              <script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
              <script src="assets/js/ie-emulation-modes-warning.js"></script>

              <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
              <!--[if lt IE 9]>
              <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
              <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
              <![endif]-->
          </head>

          <body>
          <nav class="navbar navbar-fixed-top navbar-inverse">
            <div class="container-fluid">
              <!-- Brand and toggle get grouped for better mobile display -->
              <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                </button>
               
              </div>
              <?php 
                 require_once('tpl/inc_admin.php'); 
             // require_once('system/dbConn.php');
              connect();
              $sql='select* from videotype ';
              $rs=mysql_query($sql)or die('查询1失败！'.mysql_error());
           ?>
           <ul class="nav navbar-nav">
            <li><a href="index.php">首页</a></li>
            <?php 
                  while($row=mysql_fetch_assoc($rs))
                  {
             ?>
               <li>
                   <a href="list.php?tid=<?php
                   echo $row["tid"];?>
                   "><?php 
                   echo $row["typename"];
                    ?>
                   </a></li>
                   <?php } ?>
           </ul>

            
              
                <form class="navbar-form navbar-left" role="search" action="search.php">
                  <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search" name="videoname">
                  </div>
                  <button type="submit" class="btn btn-default">搜索</button>
                </form>
                <ul class="nav navbar-nav navbar-right">
                <li class="active"> <a href="">欢迎 <?php 
                session_start();
                if (isset($_SESSION["user"]))
                  echo "  ".$_SESSION["user"]."";
              else{
                  echo"您";
              }
                 ?> 访问本网站</a></li>
                 <?php 
                 if(isset($_SESSION["user"]))
                 {
                   ?>
                   <li><a href="logout.php">注销</a></li>
                     <li class="dropdown">
                         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                         aria-haspopup="true" aria-expanded="false">个人中心<span class="caret"></span></a>
                         <ul class="dropdown-menu">
                          <li><a href="#" data-toggle="modal" data-target="#changePassword">修改个人密码</a></li>
                          <li><a href="#" data-toggle="modal" data-target="#changeInfor">修改个人信息</a></li>   
                         <li><a href="myCommentList.php">我的评价</a></li>
                         </ul>
                     </li> 
                     <?php 
                     }else{ 
                      ?>   
                  <li><a href="#" data-toggle="modal" data-target="#login">登录</a></li>
                  <li><a href="#" data-toggle="modal" data-target="#reg">注册</a></li>
               <?php 
               } 
               ?>
          </ul>
           </div>
           </div>
           </nav>
            <div class="container">
<!-- /.navbar -->

 <?php
require_once('tpl/head.php');
include_once('./system/dbConn.php');
//连接数据库
connect();
//类型 id 是通过 GET 方法提交的
//根据类型 id 从数据库中查询属于该类型的所有视频信息
$tid = $_GET['tid'];
$sql0="select * from videotype where tid=$tid";
$result0 = mysql_query($sql0) or die('查询失败！'.mysql_error());
$row0 = mysql_fetch_assoc($result0);
$sql = "select * from videos where tid={$tid}";
$result = mysql_query($sql) or die('查询失败！'.mysql_error());
//获取指定的页码
//判断是否指定第几页，如果没有指定，则显示第 1 页。
if(!isset($_GET["page"]))
$page=1;
else{
$page=$_GET["page"];
}
//获取总行数，用于计算分几页显示
$result = mysql_query($sql);
$totalrows = mysql_num_rows($result);
//定义每页显示的行数
$rowsperpage =8;
//计算从表中第几行开始输出
$start = ($page-1) * $rowsperpage;
//查询用户，从第$start 行开始，共查询$rowsperpage 行。
$sql .= " limit {$start}, {$rowsperpage}";
//echo $sql.'<br/>';
//执行 sql 语句
$result = mysql_query($sql) or die('查询失败！'.mysql_error());
//查询该类型下的下载排行信息
$sql1 = "select * from videos where tid={$tid} order by downtimes desc limit 4";
$result1 = mysql_query($sql1) or die('查询失败！'.mysql_error());

?>
<div class="row row-offcanvas row-offcanvas-right">

          <div class="col-xs-12 col-sm-9">


              <div class="row text-center">
                  <div class="col-xs-12 col-lg-12 mlist">
          <h2><?php echo $row0["typename"];?>专栏</h2>
        <ul class="list-inline row text-center">
<?php
while($row=mysql_fetch_assoc($result))
{
?>
 <li class="col-xs-4 col-sm-3col-lg-2">
<img src="./images/<?php echo $row["pic"];?>" class="responsive img-thumbnail"/>
<p><a href="show.php?vid=<?php echo $row["vid"];?>"><?php echo $row["videoname"];?></a></p></li>
<?php
}
?>
</ul>

<nav class="text-center">
<?php
//计算总页数。如果每页显示的行数>总行数，则只有 1 页，否则，页数=总行数/每页行数，上取整
if($rowsperpage >= $totalrows)
$totalpages = 1;
else{
$totalpages = ceil($totalrows / $rowsperpage);

}
//如果不是第 1 页，则显示第一页和上一页的超链接，否则只显示文字
if($page>1){
$first = "<a href=?page=1&tid=$tid>首页</a>";
$pre = "<a href=?tid=$tid&page=".($page-1).">上一页</a>";
}else{
$first = '首页';
$pre = '上一页';
}
//如果不是最后一页，则显示下一页和最后一页的超链接，否则只显示文字
if($page<$totalpages){
$last = "<a href=?tid=$tid&page=$totalpages>尾页</a>";
$next = "<a href=?tid=$tid&page=".($page+1).">下一页</a>";
}else{
$last = '尾页';
$next = '下一页';
}
//输出分页
echo "共{$totalrows}条记录&nbsp;&nbsp;";
echo "$first"."&nbsp;&nbsp;";
echo "$pre"."&nbsp;&nbsp;";
for($i=1;$i<=$totalpages;$i++)
echo "<a href=?tid=$tid&page=$i>第{$i}页</a>&nbsp;&nbsp;";
echo "$next"."&nbsp;&nbsp;";
echo "$last";
?>
</nav>
 </div>
<!--/.col-xs-6.col-lg-4-->

 </div>
 <!--/row-->
        </div>
        <!--/.col-xs-12.col-sm-9-->
       <div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar">
              <div class="list-group text-center">
                  <h2 style="color:white;" >下载排行</h2>
      <ul class="list-inline row text-center">
       
<?php
while($row1=mysql_fetch_assoc($result1))
{

?>
<li class="col-xs-12 col-lg-6">
<img src="./images/<?php echo $row1["pic"];?>" class="responsive img-thumbnail"/>
<p><a href="show.php?vid=<?php echo $row1["vid"];?>"><?php echo mb_substr($row1["videoname"],0,6,'utf-8');?></a></p>

</p>
</li>
<?php
}
?>
</ul>
    </div>
</div>    
    </div>
   
    </div>
<!--/.container-->
<hr>

   
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>

<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="assets/js/ie10-viewport-bug-workaround.js"></script>

<script src="offcanvas.js"></script>
</body>
</html>
